package alingrad.engine.src.collisions;

public class CollisionMaskData {

	private int height;
	private int width;
	private boolean[][] data;

	public CollisionMaskData(int width, int height) {
		this.width = width;
		this.height = height;
	}

	public boolean[][] getData() {
		return data;
	}

	public boolean getPixel(int x, int y) {
		if (x < 0 || x >= width || y < 0 || y >= height)
			return false;
		return data[y][x];
	}

	/**
	 * sets the data.
	 * @param data the data to set.
	 */
	public void setData(boolean[][] data) {
		this.data = data;
	}

	public int getWidth() {
		return width;
	}

	public int getHeight() {
		return height;
	}

	/**
	 * Prints out the collision mask data.
	 */
	public String toString() {
		String retval = "-----------------------------------\n";
		for (int y = 0; y < height; y++) {
			for (int x = 0; x < width; x++) {
				if (data[y][x])
					retval += "#";
				else
					retval += " ";
			}
			retval += "\n";
		}
		retval += "-----------------------------------";
		return retval;
	}
}
